#第二章
# 选择排序

#每次从原数组中选择一个最大的或者最小放进一个新的数组中
def find_small(arr):
    small = arr[0]
    small_idx = 0
    for i in range(1,len(arr)):
        if arr[i] < small:
            small = arr[i]
            small_idx = i
    return small_idx

def selection_sort(arr):
    newArr = []
    for i in range(len(arr)):
        small_idx = find_small(arr)
        newArr.append(arr.pop(small_idx))
    return newArr

src = [20,1,34,45,563,4,65,54,734,67]

print(selection_sort(src))